<!-- 分页查询 - PHP -->
<template>
	<view class="page-name">
		<cu-custom  bgColor="bgcolor-main"  :isCustom="true" :isBack="true">
			<view slot="content" >分页查询 - PHP</view>
		</cu-custom>
		<scroll-view scroll-x class="bg-white nav">
		  <view class="flex text-center">
		    <view class="cu-item flex-sub " @click="selectTab(0)" :class="curIndex==0?' cur':''" >全部</view>
			<view class="cu-item flex-sub " @click="selectTab(1)" :class="curIndex==1?' cur':''" >已报名</view>
			<view class="cu-item flex-sub " @click="selectTab(2)" :class="curIndex==2?' cur':''" >已到岗</view>
			<view class="cu-item flex-sub " @click="selectTab(3)" :class="curIndex==3?' cur':''" >未入职</view>
		  </view>
		</scroll-view>
		<scroll-view scroll-y="true" @scrolltolower="search">
			<view class="apply" v-for="(item,dex) in list">
				<view class="title flex">
					<view class="left flex-treble">{{item.title}}</view>
					<view class="right flex-sub text-right">
						<view class="status status-yellow" v-if="item.status==1">已报名</view>
						<view class="status status-blue" v-else-if="item.status==2" >已到岗</view>
						<view class="status status-red" v-else-if="item.status==3" >未入职</view>  
					</view>
					
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
export default {
	data() {
		return { 
			options:{},
			curIndex:0,
			list:[],//数据列表
		}
	}, 
	onLoad(options) {
		this.options=options;
		this.research();
	},
	onShareAppMessage(res){
		return {
			title: '',
			path:"/pages/index/index"
		}
	},
	onShow(){},
	onReachBottom(){},
	onHide(){}, 
	onReady(){},
	methods: {
		//重新从第一页开始搜索
		research:function(){
			this.list=[];
			this.$func.initPage(this);
			this.search();
		},
		selectTab(index){
			//切换状态
			if(index==this.curIndex)return false;
			this.curIndex=index;
			this.research();
		},
		search:function(){
			var _this=this;
			var datas=this.$func.nextPage(this);//读取下一页
			if(!datas)return false;//没有下一页了
			/*附加其他参数*/
			datas.status=this.curIndex;
			this.$api.request({
				url:"api/order/myapply",
				data:datas,
				success:function(res){
					_this.$func.initPage(_this,res.data);//更新分页
					_this.list=_this.list.concat(res.data.data);//拼接数据列表
				}
			})
		}
	}
}
</script>

<style lang="scss">
	.page-name{ 
		.nav{
			background-color: #419BFF;color:#fff;font-size: 26upx;
		}
		.cur{
			border-bottom: 5upx solid #fff;
		}
	}
</style>
